****************************************************************************
****************************************************************************

********************* Do file: Paper on EU budget **************************

****************************************************************************
****************************************************************************


*** Descriptives and data preparation

outreg2 using x.doc, replace sum(log) label  

tsset year, yearly

* Dependent variable: BD (Budget Distance, yearly data)

* Descriptives, density plot and possible power transformations: Budget Distance
sum BD, detail
hist BD, norm title(histogram)
kdensity BD, normal title(Budget Distance by Year) subtitle(1985-2013)
graph box BD 
ladder BD 
gladder BD 


* Time series plot: BD
twoway area BD year, sort xlabel(1979(1)2013) bcolor(gs8) ytitle(Budget distance) ttitle(Year) ///
title(Budget distance by Year) subtitle(1979-2013)

* Time series plot: Winning coalitions (w100)
twoway (tsline w100, recast(line)), xlabel(1979(1)2013, angle(45)) ylabel(0(3)16) ytitle(Winning Coalition Size) ttitle(Year) ///
title(Percentage of winning Coalitions by Year) subtitle(1979-2013) 

* Summary statistics
sum BD w100 mean_R_couW mean_R_epW mean_R_com diff_xtremes_SQR p_budgcyc cohesion_c finpersp_I finpersp_II finpersp_III finpersp_IV

* Correlations
pwcorr BD w100 mean_R_couW mean_R_epW mean_R_com diff_xtremes_SQR p_budgcyc cohesion_c finpersp_I finpersp_II finpersp_III finpersp_IV


*** Checking assumptions for OLS regression

* Unit root test for dependent variable (Dickey-Fuller test for unit root)
dfuller BD, regress
dfuller BD, lag(1)
dfuller BD, lag(2) 

* Portmantau Q-test for white noise 
wntestq BD  // Null - no serial correlation
 


********************************************************************************
************************* OLS regressions (Table 2) ****************************
********************************************************************************

	

*********** Model #1 Institutional and partisan variables (L-R Only)
regress BD lw100 lmean_R_CouW lmean_R_epW  lmean_R_com
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1) 
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #2 Institutional and partisan variables (L-R and Pro/anti EU)
regress BD lw100 lmean_R_CouW lmean_R_epW  lmean_R_com lmean_EU_couW
estimates store model2 
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1) 
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #3 Institutional and partisan variables (L-R and Pro/anti EU), with maximum ideological distance

regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com ldiff_xtremes lmean_EU_diff_xtrem
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1) 
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #4 Partisan variables and institutional variables, with control I: access of cohesion country
regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com cohesion_c
estimates store model4
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #5 Partisan variables and institutional variables, with control II: political budget cycle
regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com p_budgcyc
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #6 Partisan variables with control IV: Multiannual Financial Framework (MFF)
regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com finpersp_I finpersp_II finpersp_III finpersp_IV
outreg2 using table1.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resi


*********** Table 1 end 


*********** Plot of coefficients, comparison of model 2 and 4 (Figure 2)
coefplot (model2, label(Model 2)) (model4, label(Model 4)), drop(_cons) xline(0)





********************************************************************************
********** OLS estimations with bootstrapped SE (Table 3 - Appendix) ***********
********************************************************************************

	
*********** Model #1 Institutional and partisan variables (L-R position Only)
bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com 
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #2 Institutional and partisan variables (L-R and Pro/anti EU)Model #2 Institutional and partisan variables (L-R and Pro/anti EU)
bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com lmean_EU_couW 
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1) 
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #3 Institutional and partisan variables (L-R and Pro/anti EU), with maximum ideological distance

bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com ldiff_xtremes lmean_EU_diff_xtrem
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1) 
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #4 Partisan variables (L-R position) and institutional variables, with control I: access of cohesion country
bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com cohesion_c
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid


*********** Model #5 Partisan variables (L-R position) and institutional variables, with control II: political budget cycle
bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com p_budgcyc
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid



*********** Model #6 Partisan variables (L-R position) with control IV: Multiannual Financial Framework (MFF)
bootstrap, reps(100): regress BD lw100 lmean_R_CouW lmean_R_epW lmean_R_com finpersp_I finpersp_II finpersp_III finpersp_IV
outreg2 using table2.doc, word append label stats(coef se) bdec(3)

* Autocorrelation test 
* 1. Obtain residuals:
predict resid, resid
* 2. Test autocorrelation using Portmanteau (Q) test for residuals
wntestq resid, lag(1)  // --> No serial correlation in residuals
* 3. Check with regression of current on lagged residuals
reg resid l.resid
drop resid

********************************************************************************
***** Table 3 end 
********************************************************************************

